<!DOCTYPE html>

<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=0" name="viewport">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>一朵 - 安全中心</title>
    <!-- swiper-2.7css -->
    <link rel="stylesheet" href="__STATIC__/index/js/swiper/idangerous.swiper.css">

    <!-- swiper-2.7js -->

    <script src="__STATIC__/index/js/swiper/idangerous.swiper.min.js"></script>

    <!-- jquery-3.2.1引用 -->

    <script src="__STATIC__/index/js/global/jquery-3.2.1.min.js"></script>

    <!-- 阿里巴巴矢量图库 -->

    <link rel="stylesheet" href="http://at.alicdn.com/t/font_561814_00381rtqsoewb3xr.css">

    <!-- 公共头部 脚部 -->

    <link rel="stylesheet" href="__STATIC__/index/css/global/global.css">

    <!-- 超过1200屏幕 -->

    <link rel="stylesheet" media="screen and (min-width: 1200px)" href="__STATIC__/index/css/safety/safety1200.css" />

    <!-- 1080-1200 -->

    <link rel="stylesheet" media="screen  and (min-width: 1080px) and (max-width: 1199px) " href="__STATIC__/index/css/safety/safety1080.css"
    />

    <!-- 960-1080 -->

    <link rel="stylesheet" media="screen  and (min-width: 960px) and (max-width: 1079px) " href="__STATIC__/index/css/safety/safety960.css"
    />

    <!-- 768-959 -->

    <link rel="stylesheet" media="screen  and (min-width: 768px) and (max-width: 959px) " href="__STATIC__/index/css/safety/safety768.css"
    />

    <!-- 568-767 -->

    <link rel="stylesheet" media="screen  and (min-width: 568px) and (max-width: 767px) " href="__STATIC__/index/css/safety/safety568.css"
    />

    <!-- 375-567 -->

    <link rel="stylesheet" media="screen  and (min-width: 375px) and (max-width: 567px) " href="__STATIC__/index/css/safety/safety375.css"
    />

    <!-- 小于375-->

    <link rel="stylesheet" media="screen  and (max-width: 374px) " href="__STATIC__/index/css/safety/safety320.css" />

    <!--一引入layer-->

    <script src="__STATIC__/layer/layer.js"></script>

</head>



<body>



    <div class="M">

        <div class="m-header">

            <div>

                <span onclick="go_back();">

                    <span class="iconfont icon-xiangzuo"></span>

                    返回

                </span>

                <span>安全中心</span>

                <span>

                    {if condition="!empty($realname)"}

                    <a href="{:url('User/index')}" class="my">

                        {$realname}

                    </a>

                    {else /}

                    <a href="{:url('Login/loginin')}">登录</a>

                    <a href="{:url('Login/register')}">注册</a>

                    {/if}

                    <a href="{:url('MyCart/my_cart')}" class="car">

                        <span class="iconfont icon-gouwuche"></span>

                        <span>{$cart_num}</span>

                    </a>

                </span>

            </div>



        </div>

        <div class="m-for">

            <a href="{:url('User/edit_mobile')}">

                <i class="iconfont icon-shouji"></i>

                <span>修改登录手机号</span>

            </a>

        </div>

        <div class="m-for">

            <a href="{:url('User/edit_password')}">

                <i class="iconfont icon-lock"></i>

                <span>修改密码</span>

            </a>

        </div>

        <div class="m-for">

            <a href="{:url('Login/logout')}">

                <i class="iconfont icon-tuichu6"></i>

                <span>退出登录</span>

            </a>

        </div>

    </div>



    <div class="PC">

        <!-- 公共头部 -->

        {include file="public/p_header" /}

        <!-- 公共头部结束 -->

        <div class="pc-content">

            {include file="public/p_user" /}



            <div class="PC_right">

                {include file="public/p_user_info" /}

                <div class="pc-tihuan">

                    <div class="pc-tihuan-headline">

                        <div>

                            <p>

                                <span class="pc-zhong">

                                    <a href="{:url('User/my_center')}">修改个人信息</a>

                                </span>

                                <span>

                                    <a href="{:url('User/edit_password')}">修改密码</a>

                                </span>

                                <span>

                                    <a href="{:url('User/edit_mobile')}">更换手机号</a>

                                </span>

                            </p>

                        </div>

                    </div>

                    <div class="pc-tihuan-content">

                        <div>

                            <label for="image_file">

                                <img class="image_file" src="{if condition='empty($user.logo)'}__STATIC__/index/touxiang.png {else /}{$user.logo}{/if}" />

                                <span>修改个人头像</span>

                            </label>

                            <input type="hidden" class="image_file" name="image_file" value="" />

                            <input type="file" id="image_file" style="display:none;" onchange="uploadImg(this);" />

                        </div>

                        <div>

                            <span>手机号</span>

                            <span>{$user.mobile}</span>

                            <span>

                                <a href="{:url('User/edit_mobile')}">修改</a>

                            </span>

                            <span>仅自己可见</span>

                        </div>

                        <div>

                            <label for="pc-name">昵称</label>

                            <input type="text" id="pc-name" name="realname" value="{$user.realname}">

                        </div>

                        <div>
                            <span>性别</span>
                            <label for="pc-woman" class="pc-gender">
                                <span>
                                </span>
                                <input type="radio" name="sex" id="pc-woman" value="0" {if condition="$user.sex eq 0" } checked {/if}>
                                <span>女</span>
                            </label>
                            <label for="pc-men" class="pc-gender pc-gender-zhong">
                                <span>
                                </span>
                                <input type="radio" name="sex" id="pc-men" checked="checked" value="1" {if condition="$user.sex eq 1" } checked {/if}>
                                <span>男</span>
                            </label>
                        </div>

                        <div>
                            <span>生日</span>
                            <span id="pc-riqi">
                            </span>
                        </div>

                        <div>

                            <a href="javascript:;" onclick="check_form()">提交信息</a>

                        </div>

                    </div>

                </div>

            </div>

        </div>
        <!-- 公共脚部  -->
        {include file="public/p_footer" /}
        <!-- 公共脚部 结束 -->
    </div>

    <script src="__STATIC__/index/js/a.js"></script>

    <script>
        function uploadImg(obj) {
            // 隐藏的文本框
            var grandmaster_input = obj.previousSibling.previousSibling;
            // 预览的image标签
            var grandmaster_img = obj.previousSibling.previousSibling.previousSibling.previousSibling.firstChild.nextElementSibling;
            // 当前选中的文件
            var image_file = obj.files[0];
            // 当前选中文件的种类
            var image_file_type = image_file.type;
            // 限制上传文件的类别
            var image_type_reg =
                /^(image\/bmp|image\/gif|image\/jpeg|image\/jpg|image\/png|image\/tiff)$/i;
            // 验证上传文件的类别
            if (image_type_reg.test(image_file_type) != true) {
                layer.msg('请上传正确格式,例如 : .bmp .gif .jpeg .jpg .png .tiff', {
                    icon: 2,
                    time: 1500,
                    shade: 0.1
                }, function (index) {
                    layer.close(index);
                });
                return false;
                return;
            }
            // 创建一个文件对象
            var file_reader = new FileReader();
            // 加载文件
            file_reader.onload = function (file) {
                // 计算文件大小
                var str = file.target.result;
                str = str.substring(str.indexOf(",") + 1);
                if (str.indexOf("=") > 0) {
                    str = str.substring(0, str.indexOf("="));
                }
                var str_length = str.length;
                var file_length = parseInt(str_length - (str_length / 8) * 2);
                if (file_length >= 5242880) {
                    layer.msg('文件不允许大于 5M', {
                        icon: 2,
                        time: 1500,
                        shade: 0.1
                    }, function (index) {
                        layer.close(index);
                    });
                    return false;
                }
                // 设置图片为选中文件
                grandmaster_img.src = file.target.result;
                grandmaster_input.value = file.target.result;
            };
            file_reader.readAsDataURL(image_file);
        };
        $(function () {
            $('.pc-gender').click(function () {
                $('.pc-gender').removeClass('pc-gender-zhong');
                $(this).addClass('pc-gender-zhong');
            });
            var options = {
                "dateFormat": "bigEndian",
                "wraper": "fieldset",
                "iegend": "生日选择"
            }
            $('#pc-riqi').birthdaypicker(options);

            var year = '{$user.birthday_year}';
            var month = '{$user.birthday_month}';
            var day = '{$user.birthday_day}';
            
            var numbers = $(".birth-year").find("option"); //获取select下拉框的所有值
            for (var j = 1; j < numbers.length; j++) {
                if ($(numbers[j]).val() == year) {
                    $(numbers[j]).attr("selected", "selected");
                }
            }
            var numbers1 = $(".birth-month").find("option"); //获取select下拉框的所有值
            for (var k = 1; k < numbers.length; k++) {
                if ($(numbers1[k]).val() == month) {
                    $(numbers1[k]).attr("selected", "selected");
                }
            }
            var numbers2 = $(".birth-day").find("option"); //获取select下拉框的所有值
            for (var l = 1; l < numbers.length; l++) {
                if ($(numbers2[l]).val() == day) {
                    $(numbers2[l]).attr("selected", "selected");
                }
            }
        });

        /**
         * 检查表单信息
         */
        function check_form() {
            var logo = $('input[name=image_file]').val(); //会员头像
            var realname = $('input[name=realname]').val();
            var sex = $('input[name=sex]:checked').val();
            var birth_year = $('.birth-year option:selected').val();
            var birth_month = $('.birth-month option:selected').val();
            var birth_day = $('.birth-day option:selected').val();
            $.post("{:url('User/my_center')}", {
                    logo: logo,
                    realname: realname,
                    sex: sex,
                    birth_year: birth_year,
                    birth_month: birth_month,
                    birth_day: birth_day
                },
                function (data) {
                    if (data.code == 1) {
                        layer.msg('修改成功', {
                            icon: 1,
                            time: 1500,
                            shade: 0.1
                        }, function (index) {
                            layer.close(index);
                            location.reload();
                        });
                    } else {
                        layer.msg(data.msg, {
                            icon: 1,
                            time: 1500,
                            shade: 0.1
                        }, function (index) {
                            layer.close(index);
                        });
                    }
                }
            );
        }
        /**
         * 返回上一页
         */
        function go_back() {
            window.history.back(); //返回上一页
        }
        /**
         * 完善会员信息
         */
        function edit_member_info() {
            window.location.href = "{:url('User/my_center')}";
        }
    </script>

</body>



</html>